package com.aiit.service.impl;


import com.aiit.dao.SysPermissionDao;
import com.aiit.pojo.SysPermission;
import com.aiit.service.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class SysPermissionServiceImpl  implements SysPermissionService {

    @Autowired
    SysPermissionDao sysPermissionDao;

    @Override
    public Set<String> listPermissions(String userName) {
        List<SysPermission> permissions = sysPermissionDao.listSysPermissionsByUserName(userName);
        Set<String> result = new HashSet<String>();
        for (SysPermission permission: permissions) {
            result.add(permission.getPermissionName());
        }
        return result;
    }
}